package com.wwl.cms.controller;

import com.wwl.cms.basic.utils.SnowFlakeUtils;
import com.wwl.cms.entity.TUser;
import com.wwl.cms.repository.TUserRepository;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wwl
 * @version 1.0
 * @date 2021/12/7 16:12
 * @description:
 */
@Api(value = "/TUser", description = "用户管理(垂直拆分使用)", tags = {"TUser"})
@RestController
@RequestMapping(value = "/tUser", produces = {"application/json"})
public class TUserController {
    @Autowired
    private TUserRepository tUserRepository;
    @ApiOperation("用户添加(垂直拆分)")
    @PostMapping("/save")
    public Object save(TUser tUser){
        if (tUser.getId()==null){
            tUser.setId((Long) SnowFlakeUtils.getId(0L));
        }
        return tUserRepository.save(tUser);
    }

    /**
     * 查询
     */
    @ApiOperation("用户查询(垂直拆分)")
    @PostMapping("/find")
    public Object find(Long id){
        return tUserRepository.findById(id);
    }

}
